home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / qtalk.zip / MSKQT.QC < prev    next >
Text File  |  1996-10-02  |  30KB  |  1,352 lines

  1. /*
  2.  
  3. Multiskins + Quake Talk, Simon Francis
  4. sjfranci@csm.uwe.ac.uk
  5. 1/10/96
  6.  
  7. */
  8. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  9. void () player_run;
  10. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  11. void(vector org, vector vel, float damage) SpawnBlood;
  12. void() SuperDamageSound;
  13.  
  14.  
  15. // called by worldspawn
  16. void() W_Precache =
  17. {
  18.     precache_sound ("weapons/r_exp3.wav");  // new rocket explosion
  19.     precache_sound ("weapons/rocket1i.wav");        // spike gun
  20.     precache_sound ("weapons/sgun1.wav");
  21.     precache_sound ("weapons/guncock.wav"); // player shotgun
  22.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  23.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  24.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  25.     precache_sound ("weapons/spike2.wav");  // super spikes
  26.     precache_sound ("weapons/tink1.wav");   // spikes tink (used in c code)
  27.     precache_sound ("weapons/grenade.wav"); // grenade launcher
  28.     precache_sound ("weapons/bounce.wav");          // grenade bounce
  29.     precache_sound ("weapons/shotgn2.wav"); // super shotgun
  30.     precache_sound ("talk/ab1.wav");
  31.     precache_sound ("talk/ab2.wav");
  32.     precache_sound ("talk/lg1.wav");
  33.     precache_sound ("talk/pk1.wav");
  34.     precache_sound ("talk/pk2.wav");
  35.     precache_sound ("talk/lg2.wav");
  36. };
  37.  
  38. float() crandom =
  39. {
  40.     return 2*(random() - 0.5);
  41. };
  42.  
  43. /*
  44. ================
  45. W_FireAxe
  46. ================
  47. */
  48. void() W_FireAxe =
  49. {
  50.     local   vector  source;
  51.     local   vector  org;
  52.  
  53.     source = self.origin + '0 0 16';
  54.     traceline (source, source + v_forward*64, FALSE, self);
  55.     if (trace_fraction == 1.0)
  56.         return;
  57.     
  58.     org = trace_endpos - v_forward*4;
  59.  
  60.     if (trace_ent.takedamage)
  61.     {
  62.         trace_ent.axhitme = 1;
  63.         SpawnBlood (org, '0 0 0', 20);
  64.         T_Damage (trace_ent, self, self, 20);
  65.     }
  66.     else
  67.     {       // hit wall
  68.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  69.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  70.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  71.         WriteCoord (MSG_BROADCAST, org_x);
  72.         WriteCoord (MSG_BROADCAST, org_y);
  73.         WriteCoord (MSG_BROADCAST, org_z);
  74.     }
  75. };
  76.  
  77.  
  78. //============================================================================
  79.  
  80.  
  81. vector() wall_velocity =
  82. {
  83.     local vector    vel;
  84.     
  85.     vel = normalize (self.velocity);
  86.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  87.     vel = vel + 2*trace_plane_normal;
  88.     vel = vel * 200;
  89.     
  90.     return vel;
  91. };
  92.  
  93.  
  94. /*
  95. ================
  96. SpawnMeatSpray
  97. ================
  98. */
  99. void(vector org, vector vel) SpawnMeatSpray =
  100. {
  101.     local   entity missile, mpuff;
  102.     local   vector  org;
  103.  
  104.     missile = spawn ();
  105.     missile.owner = self;
  106.     missile.movetype = MOVETYPE_BOUNCE;
  107.     missile.solid = SOLID_NOT;
  108.  
  109.     makevectors (self.angles);
  110.  
  111.     missile.velocity = vel;
  112.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  113.  
  114.     missile.avelocity = '3000 1000 2000';
  115.     
  116. // set missile duration
  117.     missile.nextthink = time + 1;
  118.     missile.think = SUB_Remove;
  119.  
  120.     setmodel (missile, "progs/zom_gib.mdl");
  121.     setsize (missile, '0 0 0', '0 0 0');            
  122.     setorigin (missile, org);
  123. };
  124.  
  125. /*
  126. ================
  127. SpawnBlood
  128. ================
  129. */
  130. void(vector org, vector vel, float damage) SpawnBlood =
  131. {
  132.     particle (org, vel*0.1, 73, damage*2);
  133. };
  134.  
  135. /*
  136. ================
  137. spawn_touchblood
  138. ================
  139. */
  140. void(float damage) spawn_touchblood =
  141. {
  142.     local vector    vel;
  143.  
  144.     vel = wall_velocity () * 0.2;
  145.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  146. };
  147.  
  148.  
  149. /*
  150. ================
  151. SpawnChunk
  152. ================
  153. */
  154. void(vector org, vector vel) SpawnChunk =
  155. {
  156.     particle (org, vel*0.02, 0, 10);
  157. };
  158.  
  159. /*
  160. ==============================================================================
  161.  
  162. MULTI-DAMAGE
  163.  
  164. Collects multiple small damages into a single damage
  165.  
  166. ==============================================================================
  167. */
  168.  
  169. entity  multi_ent;
  170. float   multi_damage;
  171.  
  172. void() ClearMultiDamage =
  173. {
  174.     multi_ent = world;
  175.     multi_damage = 0;
  176. };
  177.  
  178. void() ApplyMultiDamage =
  179. {
  180.     if (!multi_ent)
  181.         return;
  182.     T_Damage (multi_ent, self, self, multi_damage);
  183. };
  184.  
  185. void(entity hit, float damage) AddMultiDamage =
  186. {
  187.     if (!hit)
  188.         return;
  189.     
  190.     if (hit != multi_ent)
  191.     {
  192.         ApplyMultiDamage ();
  193.         multi_damage = damage;
  194.         multi_ent = hit;
  195.     }
  196.     else
  197.         multi_damage = multi_damage + damage;
  198. };
  199.  
  200. /*
  201. ==============================================================================
  202.  
  203. BULLETS
  204.  
  205. ==============================================================================
  206. */
  207.  
  208. /*
  209. ================
  210. TraceAttack
  211. ================
  212. */
  213. void(float damage, vector dir) TraceAttack =
  214. {
  215.     local   vector  vel, org;
  216.     
  217.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  218.     vel = vel + 2*trace_plane_normal;
  219.     vel = vel * 200;
  220.  
  221.     org = trace_endpos - dir*4;
  222.  
  223.     if (trace_ent.takedamage)
  224.     {
  225.         SpawnBlood (org, vel*0.2, damage);
  226.         AddMultiDamage (trace_ent, damage);
  227.     }
  228.     else
  229.     {
  230.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  231.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  232.         WriteCoord (MSG_BROADCAST, org_x);
  233.         WriteCoord (MSG_BROADCAST, org_y);
  234.         WriteCoord (MSG_BROADCAST, org_z);
  235.     }
  236. };
  237.  
  238. /*
  239. ================
  240. FireBullets
  241.  
  242. Used by shotgun, super shotgun, and enemy soldier firing
  243. Go to the trouble of combining multiple pellets into a single damage call.
  244. ================
  245. */
  246. void(float shotcount, vector dir, vector spread) FireBullets =
  247. {
  248.     local   vector direction;
  249.     local   vector  src;
  250.     
  251.     makevectors(self.v_angle);
  252.  
  253.     src = self.origin + v_forward*10;
  254.     src_z = self.absmin_z + self.size_z * 0.7;
  255.  
  256.     ClearMultiDamage ();
  257.     while (shotcount > 0)
  258.     {
  259.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  260.  
  261.         traceline (src, src + direction*2048, FALSE, self);
  262.         if (trace_fraction != 1.0)
  263.             TraceAttack (4, direction);
  264.  
  265.         shotcount = shotcount - 1;
  266.     }
  267.     ApplyMultiDamage ();
  268. };
  269.  
  270. /*
  271. ================
  272. W_FireShotgun
  273. ================
  274. */
  275. void() W_FireShotgun =
  276. {
  277.     local vector dir;
  278.  
  279.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM); 
  280.  
  281.     self.punchangle_x = -2;
  282.     
  283.     self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  284.     dir = aim (self, 100000);
  285.     FireBullets (6, dir, '0.04 0.04 0');
  286. };
  287.  
  288.  
  289. /*
  290. ================
  291. W_FireSuperShotgun
  292. ================
  293. */
  294. void() W_FireSuperShotgun =
  295. {
  296.     local vector dir;
  297.  
  298.     if (self.currentammo == 1)
  299.     {
  300.         W_FireShotgun ();
  301.         return;
  302.     }
  303.         
  304.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM); 
  305.  
  306.     self.punchangle_x = -4;
  307.     
  308.     self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  309.     dir = aim (self, 100000);
  310.     FireBullets (14, dir, '0.14 0.08 0');
  311. };
  312.  
  313.  
  314. /*
  315. ==============================================================================
  316.  
  317. ROCKETS
  318.  
  319. ==============================================================================
  320. */
  321.  
  322. void()  s_explode1      =       [0,             s_explode2] {};
  323. void()  s_explode2      =       [1,             s_explode3] {};
  324. void()  s_explode3      =       [2,             s_explode4] {};
  325. void()  s_explode4      =       [3,             s_explode5] {};
  326. void()  s_explode5      =       [4,             s_explode6] {};
  327. void()  s_explode6      =       [5,             SUB_Remove] {};
  328.  
  329. void() BecomeExplosion =
  330. {
  331.     self.movetype = MOVETYPE_NONE;
  332.     self.velocity = '0 0 0';
  333.     self.touch = SUB_Null;
  334.     setmodel (self, "progs/s_explod.spr");
  335.     self.solid = SOLID_NOT;
  336.     s_explode1 ();
  337. };
  338.  
  339. void() T_MissileTouch =
  340. {
  341.     local float     damg;
  342.  
  343.     if (other == self.owner)
  344.         return;         // don't explode on owner
  345.  
  346.     if (pointcontents(self.origin) == CONTENT_SKY)
  347.     {
  348.         remove(self);
  349.         return;
  350.     }
  351.  
  352.     damg = 100 + random()*20;
  353.     
  354.     if (other.health)
  355.     {
  356.         if (other.classname == "monster_shambler")
  357.             damg = damg * 0.5;      // mostly immune
  358.         T_Damage (other, self, self.owner, damg );
  359.     }
  360.  
  361.     // don't do radius damage to the other, because all the damage
  362.     // was done in the impact
  363.     T_RadiusDamage (self, self.owner, 120, other);
  364.  
  365. //      sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  366.     self.origin = self.origin - 8*normalize(self.velocity);
  367.  
  368.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  369.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  370.     WriteCoord (MSG_BROADCAST, self.origin_x);
  371.     WriteCoord (MSG_BROADCAST, self.origin_y);
  372.     WriteCoord (MSG_BROADCAST, self.origin_z);
  373.  
  374.     BecomeExplosion ();
  375. };
  376.  
  377.  
  378.  
  379. /*
  380. ================
  381. W_FireRocket
  382. ================
  383. */
  384. void() W_FireRocket =
  385. {
  386.     local   entity missile, mpuff;
  387.     
  388.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  389.     
  390.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  391.  
  392.     self.punchangle_x = -2;
  393.  
  394.     missile = spawn ();
  395.     missile.owner = self;
  396.     missile.movetype = MOVETYPE_FLYMISSILE;
  397.     missile.solid = SOLID_BBOX;
  398.         
  399. // set missile speed    
  400.  
  401.     makevectors (self.v_angle);
  402.     missile.velocity = aim(self, 1000);
  403.     missile.velocity = missile.velocity * 1000;
  404.     missile.angles = vectoangles(missile.velocity);
  405.     
  406.     missile.touch = T_MissileTouch;
  407.     
  408. // set missile duration
  409.     missile.nextthink = time + 5;
  410.     missile.think = SUB_Remove;
  411.  
  412.     setmodel (missile, "progs/missile.mdl");
  413.     setsize (missile, '0 0 0', '0 0 0');            
  414.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  415. };
  416.  
  417. /*
  418. ===============================================================================
  419.  
  420. LIGHTNING
  421.  
  422. ===============================================================================
  423. */
  424.  
  425. /*
  426. =================
  427. LightningDamage
  428. =================
  429. */
  430. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  431. {
  432.     local entity            e1, e2;
  433.     local vector            f;
  434.     
  435.     f = p2 - p1;
  436.     normalize (f);
  437.     f_x = 0 - f_y;
  438.     f_y = f_x;
  439.     f_z = 0;
  440.     f = f*16;
  441.  
  442.     e1 = e2 = world;
  443.  
  444.     traceline (p1, p2, FALSE, self);
  445.     if (trace_ent.takedamage)
  446.     {
  447.         particle (trace_endpos, '0 0 100', 225, damage*4);
  448.         T_Damage (trace_ent, from, from, damage);
  449.         if (self.classname == "player")
  450.         {
  451.             if (other.classname == "player")
  452.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  453.         }
  454.     }
  455.     e1 = trace_ent;
  456.  
  457.     traceline (p1 + f, p2 + f, FALSE, self);
  458.     if (trace_ent != e1 && trace_ent.takedamage)
  459.     {
  460.         particle (trace_endpos, '0 0 100', 225, damage*4);
  461.         T_Damage (trace_ent, from, from, damage);
  462.     }
  463.     e2 = trace_ent;
  464.  
  465.     traceline (p1 - f, p2 - f, FALSE, self);
  466.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  467.     {
  468.         particle (trace_endpos, '0 0 100', 225, damage*4);
  469.         T_Damage (trace_ent, from, from, damage);
  470.     }
  471. };
  472.  
  473.  
  474. void() W_FireLightning =
  475. {
  476.     local   vector          org;
  477.  
  478.     if (self.ammo_cells < 1)
  479.     {
  480.         self.weapon = W_BestWeapon ();
  481.         W_SetCurrentAmmo ();
  482.         return;
  483.     }
  484.  
  485. // explode if under water
  486.     if (self.waterlevel > 1)
  487.     {
  488.         T_RadiusDamage (self, self, 35*self.ammo_cells, world);
  489.         self.ammo_cells = 0;
  490.         W_SetCurrentAmmo ();
  491.         return;
  492.     }
  493.  
  494.     if (self.t_width < time)
  495.     {
  496.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  497.         self.t_width = time + 0.6;
  498.     }
  499.     self.punchangle_x = -2;
  500.  
  501.     self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  502.  
  503.     org = self.origin + '0 0 16';
  504.     
  505.     traceline (org, org + v_forward*600, TRUE, self);
  506.  
  507.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  508.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  509.     WriteEntity (MSG_BROADCAST, self);
  510.     WriteCoord (MSG_BROADCAST, org_x);
  511.     WriteCoord (MSG_BROADCAST, org_y);
  512.     WriteCoord (MSG_BROADCAST, org_z);
  513.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  514.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  515.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  516.  
  517.     LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  518. };
  519.  
  520.  
  521. //=============================================================================
  522.  
  523.  
  524. void() GrenadeExplode =
  525. {
  526.     T_RadiusDamage (self, self.owner, 120, world);
  527.  
  528.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  529.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  530.     WriteCoord (MSG_BROADCAST, self.origin_x);
  531.     WriteCoord (MSG_BROADCAST, self.origin_y);
  532.     WriteCoord (MSG_BROADCAST, self.origin_z);
  533.  
  534.     BecomeExplosion ();
  535. };
  536.  
  537. void() GrenadeTouch =
  538. {
  539.     if (other == self.owner)
  540.         return;         // don't explode on owner
  541.     if (other.takedamage == DAMAGE_AIM)
  542.     {
  543.         GrenadeExplode();
  544.         return;
  545.     }
  546.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);  // bounce sound
  547.     if (self.velocity == '0 0 0')
  548.         self.avelocity = '0 0 0';
  549. };
  550.  
  551. /*
  552. ================
  553. W_FireGrenade
  554. ================
  555. */
  556. void() W_FireGrenade =
  557. {
  558.     local   entity missile, mpuff;
  559.     
  560.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  561.     
  562.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  563.  
  564.     self.punchangle_x = -2;
  565.  
  566.     missile = spawn ();
  567.     missile.owner = self;
  568.     missile.movetype = MOVETYPE_BOUNCE;
  569.     missile.solid = SOLID_BBOX;
  570.     missile.classname = "grenade";
  571.         
  572. // set missile speed    
  573.  
  574.     makevectors (self.v_angle);
  575.  
  576.     if (self.v_angle_x)
  577.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  578.     else
  579.     {
  580.         missile.velocity = aim(self, 10000);
  581.         missile.velocity = missile.velocity * 600;
  582.         missile.velocity_z = 200;
  583.     }
  584.  
  585.     missile.avelocity = '300 300 300';
  586.  
  587.     missile.angles = vectoangles(missile.velocity);
  588.     
  589.     missile.touch = GrenadeTouch;
  590.     
  591. // set missile duration
  592.     missile.nextthink = time + 2.5;
  593.     missile.think = GrenadeExplode;
  594.  
  595.     setmodel (missile, "progs/grenade.mdl");
  596.     setsize (missile, '0 0 0', '0 0 0');            
  597.     setorigin (missile, self.origin);
  598. };
  599.  
  600.  
  601. //=============================================================================
  602.  
  603. void() spike_touch;
  604. void() superspike_touch;
  605.  
  606.  
  607. /*
  608. ===============
  609. launch_spike
  610.  
  611. Used for both the player and the ogre
  612. ===============
  613. */
  614. void(vector org, vector dir) launch_spike =
  615. {
  616.     newmis = spawn ();
  617.     newmis.owner = self;
  618.     newmis.movetype = MOVETYPE_FLYMISSILE;
  619.     newmis.solid = SOLID_BBOX;
  620.  
  621.     newmis.angles = vectoangles(dir);
  622.     
  623.     newmis.touch = spike_touch;
  624.     newmis.classname = "spike";
  625.     newmis.think = SUB_Remove;
  626.     newmis.nextthink = time + 6;
  627.     setmodel (newmis, "progs/spike.mdl");
  628.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);               
  629.     setorigin (newmis, org);
  630.  
  631.     newmis.velocity = dir * 1000;
  632. };
  633.  
  634. void() W_FireSuperSpikes =
  635. {
  636.     local vector    dir;
  637.     local entity    old;
  638.     
  639.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  640.     self.attack_finished = time + 0.2;
  641.     self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  642.     dir = aim (self, 1000);
  643.     launch_spike (self.origin + '0 0 16', dir);
  644.     newmis.touch = superspike_touch;
  645.     setmodel (newmis, "progs/s_spike.mdl");
  646.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);               
  647.     self.punchangle_x = -2;
  648. };
  649.  
  650. void(float ox) W_FireSpikes =
  651. {
  652.     local vector    dir;
  653.     local entity    old;
  654.     
  655.     makevectors (self.v_angle);
  656.     
  657.     if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  658.     {
  659.         W_FireSuperSpikes ();
  660.         return;
  661.     }
  662.  
  663.     if (self.ammo_nails < 1)
  664.     {
  665.         self.weapon = W_BestWeapon ();
  666.         W_SetCurrentAmmo ();
  667.         return;
  668.     }
  669.  
  670.     sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  671.     self.attack_finished = time + 0.2;
  672.     self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  673.     dir = aim (self, 1000);
  674.     launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  675.  
  676.     self.punchangle_x = -2;
  677. };
  678.  
  679.  
  680.  
  681. .float hit_z;
  682. void() spike_touch =
  683. {
  684. local float rand;
  685.     if (other == self.owner)
  686.         return;
  687.  
  688.     if (other.solid == SOLID_TRIGGER)
  689.         return; // trigger field, do nothing
  690.  
  691.     if (pointcontents(self.origin) == CONTENT_SKY)
  692.     {
  693.         remove(self);
  694.         return;
  695.     }
  696.     
  697. // hit something that bleeds
  698.     if (other.takedamage)
  699.     {
  700.         spawn_touchblood (9);
  701.         T_Damage (other, self, self.owner, 9);
  702.     }
  703.     else
  704.     {
  705.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  706.         
  707.         if (self.classname == "wizspike")
  708.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  709.         else if (self.classname == "knightspike")
  710.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  711.         else
  712.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  713.         WriteCoord (MSG_BROADCAST, self.origin_x);
  714.         WriteCoord (MSG_BROADCAST, self.origin_y);
  715.         WriteCoord (MSG_BROADCAST, self.origin_z);
  716.     }
  717.  
  718.     remove(self);
  719.  
  720. };
  721.  
  722. void() superspike_touch =
  723. {
  724. local float rand;
  725.     if (other == self.owner)
  726.         return;
  727.  
  728.     if (other.solid == SOLID_TRIGGER)
  729.         return; // trigger field, do nothing
  730.  
  731.     if (pointcontents(self.origin) == CONTENT_SKY)
  732.     {
  733.         remove(self);
  734.         return;
  735.     }
  736.     
  737. // hit something that bleeds
  738.     if (other.takedamage)
  739.     {
  740.         spawn_touchblood (18);
  741.         T_Damage (other, self, self.owner, 18);
  742.     }
  743.     else
  744.     {
  745.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  746.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  747.         WriteCoord (MSG_BROADCAST, self.origin_x);
  748.         WriteCoord (MSG_BROADCAST, self.origin_y);
  749.         WriteCoord (MSG_BROADCAST, self.origin_z);
  750.     }
  751.  
  752.     remove(self);
  753.  
  754. };
  755.  
  756.  
  757.  
  758. /*
  759. =====================================================================
  760.  
  761. Quake Talk
  762.  
  763. =====================================================================
  764. */
  765.  
  766. void() play_abuse =
  767. {
  768.     local   float v;
  769.     local   string tmpstr;
  770.  
  771.     v = random() * 2;
  772.     if (v < 1)
  773.         tmpstr = "talk/ab1.wav";
  774.     else
  775.         tmpstr = "talk/ab2.wav";
  776.  
  777.     sound (self, CHAN_AUTO, tmpstr, 1, ATTN_NORM);
  778. };
  779.  
  780.  
  781. void() play_prekill =
  782. {
  783.     local   float v;
  784.     local   string tmpstr;
  785.  
  786.     v = random() * 2;
  787.     if (v < 1)
  788.         tmpstr = "talk/pk1.wav";
  789.     else
  790.         tmpstr = "talk/pk2.wav";
  791.     
  792.     sound (self, CHAN_AUTO, tmpstr, 1, ATTN_NORM);
  793. };
  794.  
  795.  
  796. void() play_letsgo =
  797. {
  798.     local   float v;
  799.     local   string tmpstr;
  800.  
  801.     v = random() * 2;
  802.     if (v < 1)
  803.         tmpstr = "talk/lg1.wav";
  804.     else
  805.         tmpstr = "talk/lg2.wav";
  806.     
  807.     sound (self, CHAN_AUTO, tmpstr, 1, ATTN_NORM);
  808. };
  809.  
  810.  
  811.  
  812.  
  813. /*
  814. ===============================================================================
  815.  
  816. PLAYER WEAPON USE
  817.  
  818. ===============================================================================
  819. */
  820.  
  821. void() W_SetCurrentAmmo =
  822. {
  823.     player_run ();          // get out of any weapon firing states
  824.  
  825.     self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  826.     
  827.     if (self.weapon == IT_AXE)
  828.     {
  829.         self.currentammo = 0;
  830.         self.weaponmodel = "progs/v_axe.mdl";
  831.         self.weaponframe = 0;
  832.     }
  833.     else if (self.weapon == IT_SHOTGUN)
  834.     {
  835.         self.currentammo = self.ammo_shells;
  836.         self.weaponmodel = "progs/v_shot.mdl";
  837.         self.weaponframe = 0;
  838.         self.items = self.items | IT_SHELLS;
  839.     }
  840.     else if (self.weapon == IT_SUPER_SHOTGUN)
  841.     {
  842.         self.currentammo = self.ammo_shells;
  843.         self.weaponmodel = "progs/v_shot2.mdl";
  844.         self.weaponframe = 0;
  845.         self.items = self.items | IT_SHELLS;
  846.     }
  847.     else if (self.weapon == IT_NAILGUN)
  848.     {
  849.         self.currentammo = self.ammo_nails;
  850.         self.weaponmodel = "progs/v_nail.mdl";
  851.         self.weaponframe = 0;
  852.         self.items = self.items | IT_NAILS;
  853.     }
  854.     else if (self.weapon == IT_SUPER_NAILGUN)
  855.     {
  856.         self.currentammo = self.ammo_nails;
  857.         self.weaponmodel = "progs/v_nail2.mdl";
  858.         self.weaponframe = 0;
  859.         self.items = self.items | IT_NAILS;
  860.     }
  861.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  862.     {
  863.         self.currentammo = self.ammo_rockets;
  864.         self.weaponmodel = "progs/v_rock.mdl";
  865.         self.weaponframe = 0;
  866.         self.items = self.items | IT_ROCKETS;
  867.     }
  868.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  869.     {
  870.         self.currentammo = self.ammo_rockets;
  871.         self.weaponmodel = "progs/v_rock2.mdl";
  872.         self.weaponframe = 0;
  873.         self.items = self.items | IT_ROCKETS;
  874.     }
  875.     else if (self.weapon == IT_LIGHTNING)
  876.     {
  877.         self.currentammo = self.ammo_cells;
  878.         self.weaponmodel = "progs/v_light.mdl";
  879.         self.weaponframe = 0;
  880.         self.items = self.items | IT_CELLS;
  881.     }
  882.     else
  883.     {
  884.         self.currentammo = 0;
  885.         self.weaponmodel = "";
  886.         self.weaponframe = 0;
  887.     }
  888. };
  889.  
  890. float() W_BestWeapon =
  891. {
  892.     local   float   it;
  893.     
  894.     it = self.items;
  895.  
  896.     if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
  897.         return IT_LIGHTNING;
  898.     else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  899.         return IT_SUPER_NAILGUN;
  900.     else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  901.         return IT_SUPER_SHOTGUN;
  902.     else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  903.         return IT_NAILGUN;
  904.     else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  905.         return IT_SHOTGUN;
  906.         
  907. /*
  908.     if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
  909.         return IT_ROCKET_LAUNCHER;
  910.     else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) )
  911.         return IT_GRENADE_LAUNCHER;
  912.  
  913. */
  914.  
  915.     return IT_AXE;
  916. };
  917.  
  918. float() W_CheckNoAmmo =
  919. {
  920.     if (self.currentammo > 0)
  921.         return TRUE;
  922.  
  923.     if (self.weapon == IT_AXE)
  924.         return TRUE;
  925.     
  926.     self.weapon = W_BestWeapon ();
  927.  
  928.     W_SetCurrentAmmo ();
  929.     
  930. // drop the weapon down
  931.     return FALSE;
  932. };
  933.  
  934. /*
  935. ============
  936. W_Attack
  937.  
  938. An attack impulse can be triggered now
  939. ============
  940. */
  941. void()  player_axe1;
  942. void()  player_axeb1;
  943. void()  player_axec1;
  944. void()  player_axed1;
  945. void()  player_shot1;
  946. void()  player_nail1;
  947. void()  player_light1;
  948. void()  player_rocket1;
  949.  
  950. void() W_Attack =
  951. {
  952.     local   float   r;
  953.  
  954.     if (!W_CheckNoAmmo ())
  955.         return;
  956.  
  957.     makevectors     (self.v_angle);                 // calculate forward angle for velocity
  958.     self.show_hostile = time + 1;   // wake monsters up
  959.  
  960.     if (self.weapon == IT_AXE)
  961.     {
  962.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  963.         r = random();
  964.         if (r < 0.25)
  965.             player_axe1 ();
  966.         else if (r<0.5)
  967.             player_axeb1 ();
  968.         else if (r<0.75)
  969.             player_axec1 ();
  970.         else
  971.             player_axed1 ();
  972.         self.attack_finished = time + 0.5;
  973.     }
  974.     else if (self.weapon == IT_SHOTGUN)
  975.     {
  976.         player_shot1 ();
  977.         W_FireShotgun ();
  978.         self.attack_finished = time + 0.5;
  979.     }
  980.     else if (self.weapon == IT_SUPER_SHOTGUN)
  981.     {
  982.         player_shot1 ();
  983.         W_FireSuperShotgun ();
  984.         self.attack_finished = time + 0.7;
  985.     }
  986.     else if (self.weapon == IT_NAILGUN)
  987.     {
  988.         player_nail1 ();
  989.     }
  990.     else if (self.weapon == IT_SUPER_NAILGUN)
  991.     {
  992.         player_nail1 ();
  993.     }
  994.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  995.     {
  996.         player_rocket1();
  997.         W_FireGrenade();
  998.         self.attack_finished = time + 0.6;
  999.     }
  1000.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  1001.     {
  1002.         player_rocket1();
  1003.         W_FireRocket();
  1004.         self.attack_finished = time + 0.8;
  1005.     }
  1006.     else if (self.weapon == IT_LIGHTNING)
  1007.     {
  1008.         player_light1();
  1009.         self.attack_finished = time + 0.1;
  1010.         sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1011.     }
  1012. };
  1013.  
  1014. /*
  1015. ============
  1016. W_ChangeWeapon
  1017.  
  1018. ============
  1019. */
  1020. void() W_ChangeWeapon =
  1021. {
  1022.     local   float   it, am, fl;
  1023.     
  1024.     it = self.items;
  1025.     am = 0;
  1026.     
  1027.     if (self.impulse == 1)
  1028.     {
  1029.         fl = IT_AXE;
  1030.     }
  1031.     else if (self.impulse == 2)
  1032.     {
  1033.         fl = IT_SHOTGUN;
  1034.         if (self.ammo_shells < 1)
  1035.             am = 1;
  1036.     }
  1037.     else if (self.impulse == 3)
  1038.     {
  1039.         fl = IT_SUPER_SHOTGUN;
  1040.         if (self.ammo_shells < 2)
  1041.             am = 1;
  1042.     }               
  1043.     else if (self.impulse == 4)
  1044.     {
  1045.         fl = IT_NAILGUN;
  1046.         if (self.ammo_nails < 1)
  1047.             am = 1;
  1048.     }
  1049.     else if (self.impulse == 5)
  1050.     {
  1051.         fl = IT_SUPER_NAILGUN;
  1052.         if (self.ammo_nails < 2)
  1053.             am = 1;
  1054.     }
  1055.     else if (self.impulse == 6)
  1056.     {
  1057.         fl = IT_GRENADE_LAUNCHER;
  1058.         if (self.ammo_rockets < 1)
  1059.             am = 1;
  1060.     }
  1061.     else if (self.impulse == 7)
  1062.     {
  1063.         fl = IT_ROCKET_LAUNCHER;
  1064.         if (self.ammo_rockets < 1)
  1065.             am = 1;
  1066.     }
  1067.     else if (self.impulse == 8)
  1068.     {
  1069.         fl = IT_LIGHTNING;
  1070.         if (self.ammo_cells < 1)
  1071.             am = 1;
  1072.     }
  1073.  
  1074.     self.impulse = 0;
  1075.     
  1076.     if (!(self.items & fl))
  1077.     {       // don't have the weapon or the ammo
  1078.         sprint (self, "no weapon.\n");
  1079.         return;
  1080.     }
  1081.     
  1082.     if (am)
  1083.     {       // don't have the ammo
  1084.         sprint (self, "not enough ammo.\n");
  1085.         return;
  1086.     }
  1087.  
  1088. //
  1089. // set weapon, set ammo
  1090. //
  1091.     self.weapon = fl;               
  1092.     W_SetCurrentAmmo ();
  1093. };
  1094.  
  1095. /*
  1096. ============
  1097. CheatCommand
  1098. ============
  1099. */
  1100. void() CheatCommand =
  1101. {
  1102.     if (deathmatch || coop)
  1103.         return;
  1104.  
  1105.     self.ammo_rockets = 100;
  1106.     self.ammo_nails = 200;
  1107.     self.ammo_shells = 100;
  1108.     self.items = self.items | 
  1109.         IT_AXE |
  1110.         IT_SHOTGUN |
  1111.         IT_SUPER_SHOTGUN |
  1112.         IT_NAILGUN |
  1113.         IT_SUPER_NAILGUN |
  1114.         IT_GRENADE_LAUNCHER |
  1115.         IT_ROCKET_LAUNCHER |
  1116.         IT_KEY1 | IT_KEY2;
  1117.  
  1118.     self.ammo_cells = 200;
  1119.     self.items = self.items | IT_LIGHTNING;
  1120.  
  1121.     self.weapon = IT_ROCKET_LAUNCHER;
  1122.     self.impulse = 0;
  1123.     W_SetCurrentAmmo ();
  1124. };
  1125.  
  1126. /*
  1127. ============
  1128. CycleWeaponCommand
  1129.  
  1130. Go to the next weapon with ammo
  1131. ============
  1132. */
  1133. void() CycleWeaponCommand =
  1134. {
  1135.     local   float   it, am;
  1136.     
  1137.     it = self.items;
  1138.     self.impulse = 0;
  1139.     
  1140.     while (1)
  1141.     {
  1142.         am = 0;
  1143.  
  1144.         if (self.weapon == IT_LIGHTNING)
  1145.         {
  1146.             self.weapon = IT_AXE;
  1147.         }
  1148.         else if (self.weapon == IT_AXE)
  1149.         {
  1150.             self.weapon = IT_SHOTGUN;
  1151.             if (self.ammo_shells < 1)
  1152.                 am = 1;
  1153.         }
  1154.         else if (self.weapon == IT_SHOTGUN)
  1155.         {
  1156.             self.weapon = IT_SUPER_SHOTGUN;
  1157.             if (self.ammo_shells < 2)
  1158.                 am = 1;
  1159.         }               
  1160.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1161.         {
  1162.             self.weapon = IT_NAILGUN;
  1163.             if (self.ammo_nails < 1)
  1164.                 am = 1;
  1165.         }
  1166.         else if (self.weapon == IT_NAILGUN)
  1167.         {
  1168.             self.weapon = IT_SUPER_NAILGUN;
  1169.             if (self.ammo_nails < 2)
  1170.                 am = 1;
  1171.         }
  1172.         else if (self.weapon == IT_SUPER_NAILGUN)
  1173.         {
  1174.             self.weapon = IT_GRENADE_LAUNCHER;
  1175.             if (self.ammo_rockets < 1)
  1176.                 am = 1;
  1177.         }
  1178.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1179.         {
  1180.             self.weapon = IT_ROCKET_LAUNCHER;
  1181.             if (self.ammo_rockets < 1)
  1182.                 am = 1;
  1183.         }
  1184.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1185.         {
  1186.             self.weapon = IT_LIGHTNING;
  1187.             if (self.ammo_cells < 1)
  1188.                 am = 1;
  1189.         }
  1190.     
  1191.         if ( (self.items & self.weapon) && am == 0)
  1192.         {
  1193.             W_SetCurrentAmmo ();
  1194.             return;
  1195.         }
  1196.     }
  1197.  
  1198. };
  1199.  
  1200. /*
  1201. ============
  1202. ServerflagsCommand
  1203.  
  1204. Just for development
  1205. ============
  1206. */
  1207. void() ServerflagsCommand =
  1208. {
  1209.     serverflags = serverflags * 2 + 1;
  1210. };
  1211.  
  1212. void() QuadCheat =
  1213. {
  1214.     if (deathmatch || coop)
  1215.         return;
  1216.     self.super_time = 1;
  1217.     self.super_damage_finished = time + 30;
  1218.     self.items = self.items | IT_QUAD;
  1219.     dprint ("quad cheat\n");
  1220. };
  1221.  
  1222. void() ID =
  1223. {
  1224. };
  1225.  
  1226. /*
  1227. ============
  1228. ImpulseCommands
  1229.  
  1230. ============
  1231. */
  1232. void() ImpulseCommands =
  1233. {
  1234.     if (self.impulse >= 1 && self.impulse <= 8)
  1235.         W_ChangeWeapon ();
  1236.  
  1237.     if (self.impulse == 9)
  1238.         CheatCommand ();
  1239.     if (self.impulse == 10)
  1240.         CycleWeaponCommand ();
  1241.     if (self.impulse == 11)
  1242.         ServerflagsCommand ();
  1243.     if ((self.impulse == 49) || (self.impulse == 50) || (self.impulse == 51))
  1244.     {
  1245.         if (self.impulse == 49)
  1246.         play_abuse ();
  1247.         else if (self.impulse == 50)
  1248.         play_prekill ();
  1249.         else if (self.impulse == 51)
  1250.         play_letsgo ();
  1251.     }
  1252.  
  1253.  
  1254. // *************************************************************************
  1255. // **                                                                     **
  1256. // ** M U L T I S K I N  1.1  (start)                                     **
  1257. // **                                                                     **
  1258. // *************************************************************************
  1259.  
  1260.  
  1261.     if ((self.impulse == 200) || (self.impulse == 201))
  1262.     {
  1263.         if (self.impulse == 200)
  1264.         {
  1265.         self.skin = self.skin + 1;
  1266.         if (self.skin == 19) self.skin = 0;
  1267.         } else
  1268.         if (self.impulse == 201)
  1269.         {
  1270.         self.skin = self.skin - 1;
  1271.         if (self.skin == -1) self.skin = 18;
  1272.         }
  1273.         if (self.skin == 0) centerprint(self, "SKIN: Quake himself (1)"); else
  1274.         if (self.skin == 1) centerprint(self, "SKIN: Duke Nukem 3d (2)"); else
  1275.         if (self.skin == 2) centerprint(self, "SKIN: Mr. Toad (3)"); else
  1276.         if (self.skin == 3) centerprint(self, "SKIN: the Stormtrooper (4)"); else
  1277.         if (self.skin == 4) centerprint(self, "SKIN: Jason (5)"); else
  1278.         if (self.skin == 5) centerprint(self, "SKIN: the Terminator (6)"); else
  1279.         if (self.skin == 6) centerprint(self, "SKIN: Judge Dredd (7)"); else
  1280.         if (self.skin == 7) centerprint(self, "SKIN: Hell Knight (8)"); else
  1281.         if (self.skin == 8) centerprint(self, "SKIN: Captain Picard (9)"); else
  1282.         if (self.skin == 9) centerprint(self, "SKIN: the Wizzard (10)"); else
  1283.         if (self.skin == 10) centerprint(self,"SKIN: the Predator (11)"); else
  1284.         if (self.skin == 11) centerprint(self,"SKIN: Skeleton (12)"); else
  1285.         if (self.skin == 12) centerprint(self,"SKIN: Wan-Fu (13)"); else
  1286.         if (self.skin == 13) centerprint(self,"SKIN: Henry Rollins (14)"); else
  1287.         if (self.skin == 14) centerprint(self,"SKIN: The Proffesional (15)"); else
  1288.         if (self.skin == 15) centerprint(self,"SKIN: Boba (16)"); else
  1289.         if (self.skin == 16) centerprint(self,"SKIN: The Shadow (17)"); else
  1290.         if (self.skin == 17) centerprint(self,"SKIN: NYPD Cop (18)"); else
  1291.         if (self.skin == 18) centerprint(self,"SKIN: The Avatar (19)");
  1292.     }
  1293.  
  1294. // *************************************************************************
  1295. // **                                                                     **
  1296. // ** M U L T I S K I N  1.1  (end)                                       **
  1297. // **                                                                     **
  1298. // *************************************************************************
  1299.  
  1300.  
  1301.  
  1302.  
  1303.     if (self.impulse == 255)
  1304.         QuadCheat ();
  1305.         
  1306.     self.impulse = 0;
  1307. };
  1308.  
  1309. /*
  1310. ============
  1311. W_WeaponFrame
  1312.  
  1313. Called every frame so impulse events can be handled as well as possible
  1314. ============
  1315. */
  1316. void() W_WeaponFrame =
  1317. {
  1318.     if (time < self.attack_finished)
  1319.         return;
  1320.  
  1321.     ImpulseCommands ();
  1322.     
  1323. // check for attack
  1324.     if (self.button0)
  1325.     {
  1326.         SuperDamageSound ();
  1327.         W_Attack ();
  1328.     }
  1329. };
  1330.  
  1331. /*
  1332. ========
  1333. SuperDamageSound
  1334.  
  1335. Plays sound if needed
  1336. ========
  1337. */
  1338. void() SuperDamageSound =
  1339. {
  1340.     if (self.super_damage_finished > time)
  1341.     {
  1342.         if (self.super_sound < time)
  1343.         {
  1344.             self.super_sound = time + 1;
  1345.             sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  1346.         }
  1347.     }
  1348.     return;
  1349. };
  1350.  
  1351.  
  1352.